function [ f, g ] = bgfsPost( S, row, col, val, U, V, grad )

res = partXY((U*S)', V', row, col, length(row));
res = res' - val;

% function value
f = (1/2)*sum(res.^2);

% gradient
if nargout > 1
    grad = setSval(grad, res, length(res));
    g = full(U'*grad*V);
end

end

